<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App;

class BalanceLogModel extends Model
{
    protected $table = 'balance_log';

    protected $guarded = [
        'id'
    ];


    public function user()
    {
        return $this->belongsTo(User::class);
    }


    public function relate()
    {

        switch($this->getAttribute('type')) {
            case App\Constant::BALANCE_LOG_TYPE_RECHARGE :
                return $this->belongsTo(Wallet::class, 'trade_id', 'id');
                break;
            case App\Constant::BALANCE_LOG_TYPE_RECHARGE_PROFIT :
                return $this->belongsTo(Wallet::class, 'trade_id', 'id');
                break;
        }
    }

}
